﻿// returns the requested help message as a string
// paragraphs must be broken by <br /> tags, as the string will be contained within a pair of <p> tags
function getMessage(selection) {
    var helpMessage = new Array;

    // credit card security code help
    helpMessage[0] = "The security code is an added layer of protection designed to show that you are in " +
                        "posession of the card in question.<br /><br />" +
                        "On Visa/Mastercard/Discover credit or debit cards the security code is a group " +
                        "of three digits on the back of the card to the right of the signature strip." +
                        "<br /><br />" +
                        "On American Express cards, the security code is a group of four digits printed, " +
                        "not embossed, toward the right edge of the front of the card.";

    // Search.aspx help
    helpMessage[1] = "Type the name of an event or artist into the search box and click the search " +
                        "button. If you do no enter anything or enter invalid characters, the search box " +
                        "will instruct you to &quot;Try Again.&quot; Otherwise, you will be taken to " +
                        "your search results.<br /><br />" +
                        "Once you see the search results, you can select an event by clicking on it. You " +
                        "will be taken to a screen where you can select your seat(s).";

    // Checkout.aspx help
    helpMessage[2] = "In each of the checkout screens, required fields are highlighted in yellow. Once " +
                        "you click the button to proceed to the next screen, if any of the required " +
                        "fields are incomplete or if any fields contain invalid characters, those fields " +
                        "will be highlighted in yellow for you to change or complete.<br /><br />" +
                        "You will be required to choose a payment method <strong>and</strong> a shipping " +
                        "method before you can proceed.<br /><br />" +
                        "Do not forget to check the &quot;Authorize&quot; box when entering payment " +
                        "information.";

    // SignUp.aspx help
    helpMessage[3] = "Required fields are highlighted in yellow. Once you click the &quot;Submit&quot; " +
                        "button, if any of the required fields are incomplete or if any fields contain " +
                        "invalid characters, those fields will be highlighted in yellow for you to " +
                        "change or complete.";

    // LogIn.aspx help
    helpMessage[4] = "Type valid credentials (user name and password) into the text boxes and click the " +
                        "&quot;Submit&quot; button. If you intend to log in as an administrator, you " +
                        "<strong>must</strong> check the &quot;Log in as administrator&quot; box " +
                        "<strong>before</strong> clicking the &quot;Submit&quot; button.<br /><br />" +
                        "If either of the fields are incomplete or filled with invalid characters you " +
                        "will not be able to proceed, although you can change your entries and submit " +
                        "again.<br /><br />" +
                        "If you enter invalid credentials (wrong user name or password), you will be " +
                        "notified and instructed to try again. If you are inactive for a long period of " +
                        "time, you will be instructed to re-enter your credentials before proceeding.";

    // Account.aspx help
    helpMessage[5] = "You may use the &quot;Account&quot; page to edit your account settings. Once you " +
                        "click the &quot;Submit&quot; button, if any of the required fields are " +
                        "Incomplete or if any fields contain invalid characters, those fields will be " +
                        "highlighted in yellow for you to change or complete.";

    // GetTickets.aspx help
    helpMessage[6] = "Select a section, then a row from that section, then a seat number. The price will" +
                        "display below once you have selected all three and will show you the cost. If" +
                        "this is agreeable, then go ahead and click &quot;Proceed.&quot; Otherwise, " +
                        "change your selection(s) until you find a price you like before you proceed.";

    // Help.aspx example
    helpMessage[7] = "When you click on a <span class='help'>HELP</span> link a pop-up window like this " +
                        "will guide you through what you are trying to do.<br /><br />" +
                        "Usually, <span class='help'>HELP</span> links are located next to the fields " +
                        "that they explain, or next to &quot;Submit/Proceed&quot; buttons.";

    return helpMessage[selection];
}

function getHelp(txt) {
    createCustomAlert(txt, "Stubby Help:", false);
}

function getModal(txt, heading) {
    createCustomAlert(txt, heading, true);
}

/*********************************************
  Custom Alert Demonstration
  version 1.0 [modified for Stubby as noted]
  last revision: 02.02.2005
  steve@slayeroffice.com

  Please leave this notice in tact!
*********************************************/

// removed constants that controled the title and button text
// removed code that overloads the alert() method 
// alert() overloading was unnecessary, and removed ability to use original alert box
// modified the CSS provided in Alert.css to customize appearance and reposition buttons

function createCustomAlert(customTxt, customTitle, secondButton) {
    d = document;

    if (d.getElementById("modalContainer")) return;

    mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
    mObj.id = "modalContainer";
    mObj.style.height = d.documentElement.scrollHeight + "px";

    alertObj = mObj.appendChild(d.createElement("div"));
    alertObj.id = "alertBox";
    if (d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
    alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth) / 2 + "px";
    alertObj.style.visiblity = "visible";

    h1 = alertObj.appendChild(d.createElement("h1"));
    h1.appendChild(d.createTextNode(customTitle)); // originally controlled by a now defunct constant

    msg = alertObj.appendChild(d.createElement("p"));
    msg.innerHTML = customTxt;

    btn = alertObj.appendChild(d.createElement("a"));
    btn.id = "closeBtn";
    btn.appendChild(d.createTextNode("OK")); // originally controlled by a now defunct constant
    btn.href = "#";
    btn.focus();
    btn.onclick = function () { removeCustomAlert(); return true; }

    // this block is original code to add the cancel button if requested by caller
    if (secondButton == true) {
        btn.id = "OKbutton";
        sbtn = alertObj.appendChild(d.createElement("a"));
        sbtn.id = "cancelBtn";
        sbtn.appendChild(d.createTextNode("Cancel"));
        sbtn.href = "#";
        sbtn.focus();
        sbtn.onclick = function () { removeCustomAlert(); return false; }
    }

    alertObj.style.display = "block";
}

function removeCustomAlert() {
    document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}